import request from "@/utils/request";
import { ParamsType } from "@/api/corp/project/types";
import { PayrollDetailForm, ProjectTeamForm } from "@/api/manager/project/types";

/**
 * 获取项目管理列表
 */
export function getProjectMagList(data: ParamsType) {
  return request({
    url: "/api/v1/corp/project/project_page",
    method: "get",
    params: data,
  });
}

/**
 * 获取项目管理列表
 */
export function getProjectMagInfo(projectId: number) {
  return request({
    url: `api/v1/corp/project/${projectId}/projectform`,
    method: "get",
  });
}

/**
 * 获取专户列表
 */
export function getProjectAccountList(data: ParamsType) {
  return request({
    url: "/api/v1/corp/projectspecialaccount/page",
    method: "get",
    params: data,
  });
}

/**
 * 获取专户信息
 */
export function getProjectAccountInfo(id: number) {
  return request({
    url: `api/v1/corp/projectspecialaccount/${id}/form`,
    method: "get",
  });
}

/**
 * 获取考勤明细列表
 */
export function getAttendanceList(data: ParamsType) {
  return request({
    url: "/api/v1/corp/checkindetail/page",
    method: "get",
    params: data,
  });
}

/**
 * 获取工资单列表
 */
export function getPayrollList(data: ParamsType) {
  return request({
    url: "/api/v1/corp/wagepayroll/page",
    method: "get",
    params: data,
  });
}

/**
 * 获取工资单信息
 */
export function getPayrollInfo(id: number) {
  return request({
    url: `api/v1/corp/wagepayroll/${id}/form`,
    method: "get",
  });
}

/**
 * 获取工资单明细详情信息
 */
export function getPayrollDetail(id: number) {
  return request({
    url: "/api/v1/corp/wagepayrolldetail/" + id,
    method: "get",
  });
}

/**
 * 新增工资单信息
 */
export function addPayroll(data: ProjectTeamForm) {
  return request({
    url: "/api/v1/corp/wagepayroll/create",
    method: "post",
    data: data,
  });
}

/**
 * 修改工资单信息
 */
export function editPayroll(id: number, data: ProjectTeamForm) {
  return request({
    url: "/api/v1/corp/wagepayroll/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除工资单信息
 */
export function deletePayroll(id: number) {
  return request({
    url: "/api/v1/corp/wagepayroll/" + id,
    method: "delete",
  });
}

/**
 * 提交工资单明细详情信息
 */
export function putPayrollDetail(id: number, data: PayrollDetailForm) {
  return request({
    url: "/api/v1/corp/wagepayrolldetail/addWagePayrollDetails/" + id,
    method: "post",
    data: data,
  });
}

/**
 * 获取工资单审核记录
 */
export function getPayrollInfoAuditLogs(id: number) {
  return request({
    url: "/api/v1/corp/wagepayroll/auditLogs?id=" + id,
    method: "get",
  });
}

/**
 * 提交工资单信息
 */
export function submitPayroll(id) {
  return request({
    url: "/api/v1/corp/wagepayroll/submit/" + id,
    method: "post",
  });
}

/**
 * 获取工资单明细详情信息
 */
export function getCorpManagerList(param) {
  return request({
    url: "/api/v1/corp/manager/page",
    method: "get",
    params: param,
  });
}

/**
 * 项目管理员设置
 */
export function updateManager(projectId, data) {
  return request({
    url: "/api/v1/corp/project/updateManager/" + projectId,
    method: "put",
    params: data,
  });
}

/**
 * 工资单审核
 */
export function auditPayroll(id, data) {
  return request({
    url: "/api/v1/corp/wagepayroll/audit/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 企业角色
 */
export function getProjectCorpRole() {
  return request({
    url: "/api/v1/corp/common/projectCorpRole",
    method: "get",
  });
}

/**
 * 获取项目班组下拉列表
 */
export function getProjectTeamPulldownList() {
  return request({
    url: "/api/v1/corp/projectgroup/getProjectCorps",
    method: "get",
  });
}

/**
 * 获取项目班组列表
 */
export function getProjectTeamList(data: ParamsType) {
  return request({
    url: "/api/v1/corp/projectgroup/page",
    method: "get",
    params: data,
  });
}

/**
 * 根据班组ID 获取班组人员列表
 */
export function getProjectTeamMemberListByTeamId(id) {
  return request({
    url: "/api/v1/corp/projectgroupmember/getProjectGroupMemberByGroupId/" + id,
    method: "get",
  });
}

/**
 * 获取班组信息
 */
export function getProjectTeamInfo(id: number) {
  return request({
    url: `api/v1/corp/projectgroup/${id}/form`,
    method: "get",
  });
}

/**
 * 获取人员信息
 */
export function getPersonInfo(id: number) {
  return request({
    url: `api/v1/corp/person/${id}/form`,
    method: "get",
  });
}

/**
 * 导出工资明细模板
 */
export function downloadPayroll(id: number) {
  return request({
    url: "/api/v1/corp/wagepayroll/exportTemplate/" + id,
    method: "get",
    responseType: "arraybuffer",
  });
}

/**
 * 导出工资明细模板
 */
export function exportPayrollDetail(id: number) {
  return request({
    url: "/api/v1/corp/wagepayroll/exportDetail/" + id,
    method: "get",
    responseType: "arraybuffer",
  });
}
